package com.example.demo1.util;/*package com.example.demo1.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class MyBatisUtil {
    private static SqlSessionFactory ssf;

    static {
        try {
            // 1. 读取配置文件 mybatis-config.xml
            InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
            // 2. 根据配置文件构建SqlSessionFactory
            ssf  = new SqlSessionFactoryBuilder().build(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static SqlSession getSqlSession(){
        // 3. 通过SqlSessionFactory创建SqlSession
        return ssf.openSession(true);//true:开启事务自动提交；默认为false，即事务不会自动提交
    }
}
*/
